const initValue = {
  userChannels: [],
  allUserChannelList: [],
  articles: {},
  moreAction: {
    // 控制弹出菜单的显示隐藏
    visible: false,
    // 当前反馈的目标文章ID
    articleId: 0,
  },
}
export default function Home(state = initValue, action) {
  const { type, payload } = action
  switch (type) {
    case 'home/channels':
      return {
        ...state,
        userChannels: payload,
      }
    case 'home/allChannels':
      return {
        ...state,
        allUserChannelList: payload,
      }
    case 'home/articleList':
      return {
        ...state,
        articles: {
          ...state.articles,
          [payload.channelId]: {
            timestamp: payload.timestamp,
            list: payload.list,
          },
        },
      }
    case 'home/moreArticle':
      return {
        ...state,
        articles: {
          ...state.articles,
          [payload.channelId]: {
            timestamp: payload.timestamp,
            list: [...state.articles[payload.channelId].list, ...payload.list],
          },
        },
      }
    case 'home/moreAction':
      return {
        ...state,
        moreAction: payload,
      }
    default:
      return state
  }
}
